home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7716 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is &Variable (declared as: char Variable[10])?
  5. Date: 27 Feb 1996 15:47:07 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb27084707@qcd.lanl.gov>
  8. References: <4gqpa1$3h9@alcor.usc.edu> <1996Feb26.211807.28858@isac.hces.com>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: gg@isac.hces.com's message of Mon, 26 Feb 1996 21:18:07 GMT
  13.  
  14. In article <1996Feb26.211807.28858@isac.hces.com>
  15. gg@isac.hces.com (Greg Goodrich) writes:
  16.  
  17. GG: This is because C treats the occurrence of array names as the address of
  18. GG: the array.  Therefore the following are equivalent:
  19. GG: 
  20. GG:     scanf("%s", myarray);
  21. GG:     scanf("%s", &myarray);
  22. GG: 
  23.  
  24. I am amazed at the number of wrong answers this simple question
  25. got. myarray and &myarray are equivalent in exactly the same sense
  26. that 1 and 1.0 are equivalent. myarray is a pointer to char (it is the
  27. same as &myarray[0]), whereas myarray ia a pointer to an array of 10
  28. chars. Only the first ought to be passed to scanf when the format
  29. specified is %s.
  30.  
  31. Cheers
  32. Tanmoy
  33. --
  34. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  35. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  36. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  37. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  38. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  39. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  40.